cmake_minimum_required (VERSION 2.6)
project (OldSchoolGame)

set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "Build the GLFW example programs")
set(GLFW_BUILD_TESTS OFF CACHE BOOL "Build the GLFW test programs")
set(GLFW_BUILD_DOCS OFF CACHE BOOL "Build the GLFW documentation")
set(GLFW_INSTALL OFF CACHE BOOL "Generate installation target")

set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "-pipe -std=c++11 -Wall -Wextra -pedantic -O2 -Os -fno-exceptions -fno-rtti")
set(CMAKE_CXX_LINK_FLAGS "")

if(DEBUG_TARGET)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -g3")
    message(STATUS "${PROJECT_NAME} target: DEBUG")
elseif(RELEASE_TARGET)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -DNDEBUG -mtune=native -march=native")
    if(CMAKE_COMPILER_IS_GNUCXX)
            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -DNDEBUG -mtune=native -march=native -ffunction-sections -fdata-sections")
            set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -s -Wl,--gc-sections")
    endif()
    message(STATUS "${PROJECT_NAME} target: RELEASE")
else()
    if(CMAKE_COMPILER_IS_GNUCXX)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
        set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--gc-sections")
    endif()
    message(STATUS "${PROJECT_NAME} target: DEFAULT")
endif()

add_subdirectory(glfw)
add_subdirectory(gmock)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/glfw/include)
add_subdirectory(src)

add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} OSG glfw ${GLFW_LIBRARIES})
